package band.wukong.practice.javase.core.io.standardio;

import java.io.*;

/**
 * Created by IntelliJ IDEA.
 * User: Johnson
 * Date: 2012-8-24 10:29:57
 * To change this template use File | Settings | File Templates.
 */
public class Redirecting {

    private static final String FILE_IN = "D:\\WorkZone\\lab\\TestJava\\src\\com\\jsun\\javase\\corepackage\\io\\standardio\\Redirecting.java";
    private static final String FILE_OUT = "D:\\WorkZone\\lab\\TestJava\\src\\com\\jsun\\javase\\corepackage\\io\\testdir\\Redirecting.java.out";

    
    public static void main(String[] args)
            throws IOException {
        PrintStream console = System.out;
        BufferedInputStream in = new BufferedInputStream(
                new FileInputStream(FILE_IN));
        PrintStream out = new PrintStream(
                new BufferedOutputStream(
                        new FileOutputStream(FILE_OUT)));
        System.setIn(in);
        System.setOut(out);
        System.setErr(out);
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        String s;
        while ((s = br.readLine()) != null)
            System.out.println(s);
        out.close(); // Remember this!
        System.setOut(console);
    }
}
